﻿#ifndef FILTHEME_H
#define FILTHEME_H

#include <QObject>
#include <QtQml>
#include <QColor>
#include <QTimer>
#include <QMutex>
#include <QFileSystemWatcher>

#include "filaccentcolor.h"
#include "../common/stdafx.h"
#include "../common/singleton.h"

class FilTheme : public QObject
{
    Q_OBJECT
    Q_PROPERTY_AUTO_P(FilAccentColor *, accentColor)
    Q_PROPERTY_AUTO(QColor, primaryColor)
    Q_PROPERTY_AUTO(QColor, backgroundColor)
    Q_PROPERTY_AUTO(QColor, dividerColor)
    Q_PROPERTY_AUTO(QColor, windowBackgroundColor)
    Q_PROPERTY_AUTO(QColor, windowActiveBackgroundColor)
    Q_PROPERTY_AUTO(QColor, fontPrimaryColor)
    Q_PROPERTY_AUTO(QColor, fontSecondaryColor)
    Q_PROPERTY_AUTO(QColor, fontTertiaryColor)
    Q_PROPERTY_AUTO(QColor, itemNormalColor)
    Q_PROPERTY_AUTO(QColor, frameColor)
    Q_PROPERTY_AUTO(QColor, frameActiveColor)
    Q_PROPERTY_AUTO(QColor, itemHoverColor)
    Q_PROPERTY_AUTO(QColor, itemPressColor)
    Q_PROPERTY_AUTO(QColor, itemCheckColor)
    Q_PROPERTY_AUTO(QString, desktopImagePath)
    Q_PROPERTY_AUTO(bool, nativeText)
    Q_PROPERTY_AUTO(bool, animationEnabled)
    Q_PROPERTY_AUTO(bool, blurBehindWindowEnabled)
    QML_NAMED_ELEMENT(FilTheme)
    QML_SINGLETON

private:
    explicit FilTheme(QObject *parent = nullptr);
    bool eventFilter(QObject *obj, QEvent *event) override;
    void refreshColors();

protected:
    void timerEvent(QTimerEvent *event) override;
    void checkUpdateDesktopImage();

public:
    SINGLETON(FilTheme)
    static FilTheme *create(QQmlEngine *engine, QJSEngine *jsengine) {
        return getInstance();
    }

private:
    QMutex _mutex;
    QFileSystemWatcher _watcher;

signals:
};

#endif // FILTHEME_H
